/**
 * <p>
 * </p>
 *
 * @author zhuolin
 * @since 2020/5/29
 */
public class AccountSync implements Runnable {

    static AccountSync instance = new AccountSync();

    static int i = 0;

    @Override
    public void run() {
        for (int j = 0; j < 10000; j++) {
            increase();
        }
    }

    public synchronized void increase() {
        i++;
    }

    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(instance);
        Thread t1 = new Thread(instance);
        t.start();
        t1.start();
        t.join();
        t1.join();
        System.out.println(i);
    }
}
